<html>
<head>
	<meta charset="UTF-8">
	<title>发表留言</title>
</head>
<body>
	<?php 
	session_start();	
	require("./system/dbConn.php");
	connect();
	//收集表单元素的值
	$vid=$_POST["vid"];
	$content=$_POST["content"];
	$username=$_SESSION["username"];

	//根据username查uid
$sql="select uid from users where uname='$username'";
$result=mysql_query($sql);
$row=mysql_fetch_assoc($result);
$uid=$row["uid"];

//添加留言信息
$sql0="insert into comments values(null,'$content',now(),'$uid','$vid')";
 // var_dump($sql0);
$result0=mysql_query($sql0);
//var_dump($result0);
//echo $sql0;
// $row0=mysql_fetch_assoc($result0);
if ($result0) {
	echo "留言添加成功,3秒后返回";
	header("refresh:3;url='show.php?vid=$vid'");
}else{
	echo "留言添加失败";
}
	 ?>
</body>
</html>